﻿using SlamCms.Common;

namespace SlamCms.Data
{
	public static class TagTreeNodeExtensions
	{
		public static bool IsTag(this TagTreeNode tagTreeNode)
		{
			return tagTreeNode.Type == TagTreeNodeType.Tag;
		}

		public static bool IsTagCategory(this TagTreeNode tagTreeNode)
		{
			return tagTreeNode.Type == TagTreeNodeType.TagCategory;
		}

		public static bool IsTopLevelTag(this TagTreeNode tagTreeNode)
		{
			return tagTreeNode.IsTag() && tagTreeNode.Parent != null && tagTreeNode.Parent.Type == TagTreeNodeType.TagCategory;
		}

		public static bool BelongsToTagCategory(this TagTreeNode tagTreeNode, params string[] tagCategoryIds)
		{
			return tagTreeNode.TagCategory != null && tagTreeNode.TagCategory.TagCategoryId.In(tagCategoryIds);
		}
	}
}
